package com.ic.loan.activity

import android.os.Bundle
import com.blankj.utilcode.util.ActivityUtils
import com.gyf.immersionbar.ktx.immersionBar
import com.ic.loan.R
import com.ic.loan.http.ApiUrl
import com.ic.loan.http.HttpUtils
import com.ic.loan.http.ResultListener
import kotlinx.android.synthetic.main.activity_contact_us.*

class ContactUsActivity : BaseActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        immersionBar {
            statusBarDarkFont(true)
        }
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_contact_us)
        ivBack.setOnClickListener { onBackPressed() }
        tvRefund.setOnClickListener {
            ActivityUtils.startActivity(RefundActivity::class.java)
        }
        tvSubmit.setOnClickListener {
            submit()
        }
    }

    private fun submit() {
        val mobile = edtMobile.text.toString()
        val content = edtContent.text.toString()
        if (mobile.isNullOrBlank()){
            return
        }
        if (content.isNullOrBlank()){
            return
        }
        showLoading()
        HttpUtils.postOkGo(mutableMapOf(
            "content" to content,
            "mobile" to mobile
        ),ApiUrl.POST_CONTACT_FEEDBACK,object : ResultListener() {
            override fun onSucceeded(json: String?) {

            }

            override fun onLoadFinish() {
                super.onLoadFinish()
                hintLoading()
            }
        },true)
    }
}